﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Framework;
using Com.Framework.Data;
using Com.Framework.Enc;
using Com.Library.DB.User;
using Com.Web.coffinegurunaru.AppLogic.Page;

namespace Com.Web.coffinegurunaru.mypage
{
	public partial class member_out : WebPage
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			this.LeftMenuType = 5;

			if (this.IsPostBack)
			{
				string UserID = Request.Form["UserID"].Parse(string.Empty);
				string UserPWD = Request.Form["UserPWD"].Parse(string.Empty);
				UserEntity info = UserModel.UserInfo(UserID);
				if ( info.UserNo == 0 )
				{
					Response.Write("<script>alert('존재하지 않는 회원입니다.');location.href='/mypage/member_out.aspx';</script>");
					Response.End();
				}

				if (info.UserID != UserID)
				{
					Response.Write("<script>alert('아이디가 정확하기 않습니다.');location.href='/mypage/member_out.aspx';</script>");
					Response.End();
				}

				if (info.MD5PWD != Crypt.MD5HashCrypt(UserPWD))
				{
					Response.Write("<script>alert('비밀번호가 틀렸습니다.');location.href='/mypage/member_out.aspx';</script>");
					Response.End();
				}

				UserModel.Remove(this.WebCookies.UserNo);
				WebCookies.Clear();
				Response.Write("<script>alert('정상적으로 탈퇴처리되었습니다.');location.href='/mypage/member_out.aspx';</script>");
				Response.End();
			}
		}
	}
}
